package 测试;

import java.util.Scanner;

public class _问题H {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int bigCount = sc.nextInt();
        sc.nextLine();
        for (int i = 1; i <= bigCount; i++) {
            int count = sc.nextInt();
            sc.nextLine();
            int[] arr = new int[count];
            for (int j = 0; j < count; j++) {
                arr[j] = sc.nextInt();
            }
            sc.nextLine();
//            Thread.sleep(5000);
            // 已经获取到了这个数组
            int score = 0;
            for (int j = 0; j < count; j++) {
                int temp = game(arr, j + 1);
                score = Math.max(score, temp);
            }
            System.out.println(score);
        }
    }

    private static int game(int[] arr, int i) {
        if (i > arr.length) {
            return 0;
        }
        int score = arr[i - 1];
        int num = i + arr[i - 1];
        if (num <= arr.length) {
            score += game(arr, num);
        }
        return score;
    }
}
